package cn.edu.lzu.dao;

import cn.edu.lzu.entity.MedicalExamineItem;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @PackageName: cn.edu.lzu.dao
 * @InterfaceName: MedicalExamineItemMapper
 * @Description: TODO
 * @Author: 张琦[QQ:3098086691]
 * @Date: 2020/3/26 14:11
 * @Version: 1.0
 */
@Mapper
public interface MedicalExamineItemMapper {
    @Select("select * from medical_examine_item where is_deleted=0 and unit_id=#{unitId} limit #{startIndex}, #{pageSize}")
    List<MedicalExamineItem> selMedItemByUnitId(long unitId, int startIndex, int pageSize);

    @Select("select count(*) from medical_examine_item where is_deleted=0 and unit_id=#{unitId}")
    int selMedItemTotalCount(long unitId);

    @Update("update medical_examine_item set is_deleted=1 where examine_item_id=#{examineItemId}")
    int updDeleteMedItemById(int examineItemId);

    @Insert("insert into medical_examine_item (examine_item_id, examine_name, price, apply_sex, apply_range, unit_id, fill_status, is_deleted) values(default, #{examineName}, #{price}, #{applySex}, #{applyRange}, #{unitId}, 0, 0)")
    int insMedExamineItem(MedicalExamineItem medicalExamineItem);

    @Select("select * from medical_examine_item where is_deleted=0 and unit_id=#{unitId}")
    List<MedicalExamineItem> selAllMedItems(long unitId);

    @Select("select * from medical_examine_item where is_deleted=0 and examine_item_id=#{examineItemId}")
    MedicalExamineItem selByExamineItemId(int examineItemId);
}
